<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../Templates/InnerSystemTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="head-title">
        <title>Message Me | Merlion's ERP System</title>
    </ui:define>
    <ui:define name="content">
        <f:view beforePhase="#{generateSalesOperationPlan.initView(event)}"></f:view>
        <h:form prependId="false">   
            <p:panel>
                <h:selectOneMenu value="#{generateSalesOperationPlan.startMonth}" required="true" requiredMessage="input start month">
                    <f:selectItem itemLabel="Select One" itemValue="" />  
                    <f:selectItems value="#{generateSalesOperationPlan.monthList}" />  
                </h:selectOneMenu>

                <h:selectOneMenu value="#{generateSalesOperationPlan.endMonth}" required="true" requiredMessage="input end month">
                    <f:selectItem itemLabel="Select One" itemValue="" />  
                    <f:selectItems value="#{generateSalesOperationPlan.monthList}" />  
                </h:selectOneMenu>
                
                <p:commandButton value="Retrieve Sales Forecast" actionListener="#{generateSalesOperationPlan.retrieveMonthlyData(event)}" update="table" ajax="true" />

                <p:dataTable id="table" var="monthlyData" value="#{generateSalesOperationPlan.monthlyData}">  
                    <p:column>
                        <f:facet name="header">
                            Month
                        </f:facet> 
                        <h:outputText value="#{monthlyData.monthName}" /> 
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            Sales Forecast
                        </f:facet> 
                        <h:outputText value="#{monthlyData.monthlyForecast}" /> 
                    </p:column> 
                    <p:column>
                        <f:facet name="header">
                            Production Plan
                        </f:facet> 
                        <p:inputText value="#{monthlyData.productionPlan}"/> 
                    </p:column> 
                    <p:column>
                        <f:facet name="header">
                            Inventory
                        </f:facet> 
                        <h:outputText value="#{monthlyData.inventory}" /> 
                    </p:column>
                </p:dataTable>
                <p:commandButton value="Refresh" actionListener="#{generateSalesOperationPlan.refresh(event)}" update="table" ajax="true" />
                <p:commandButton value="Submit" actionListener="#{generateSalesOperationPlan.generate(event)}" ajax="true" />
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>